using JetBrains.Annotations;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using Volo.Abp;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.Validation;

namespace MemberManagement;

[Index(nameof(Name))]
public class Member : FullAuditedAggregateRoot<Guid>
{
    [NotNull]
    [Required]
    [DynamicMaxLength(typeof(MemberConsts), nameof(MemberConsts.MaxNameLength))]
    public virtual string Name { get; protected set; }

    public virtual string No { get; set; }

    [NotNull]
    [Required]
    [DynamicMaxLength(typeof(MemberConsts), nameof(MemberConsts.MaxPhoneNumberLength))]
    public virtual string PhoneNumber { get; protected set; }

    public virtual Gender Gender { get; set; } = Gender.Unknown;

    public virtual DateTime BirthDate { get; set; }

    public virtual string PlaceOfOwnership { get; set; }

    public virtual Guid? CompanyId { get; set; }

    public virtual string Bank { get; set; }

    public virtual string EmailAddress { get; set; }

    public virtual bool IsBindWeb { get; set; }

    public virtual DateTime NextBirthDay { get; set; }

    public virtual MemberStatus MemberStatus { get; set; }

    public virtual Guid ManageStore { get; set; }

    public virtual Guid JoinStore { get; set; }

    public virtual DateTime JoinTime { get; set; }

    public virtual JoinType JoinType { get; set; }

    public virtual JoinChannel JoinChannel { get; set; }

    public virtual string FirstOrderNo { get; set; }

    public virtual DateTime FirstOrderedTime { get; set; }

    public virtual DateTime LastOrderedTime { get; set; }

    public virtual Guid Inviter { get; set; }

    public virtual int InviteTimes { get; set; }

    public virtual Guid MemberLevel { get; set; }

    public virtual DateTime PlusExpiration { get; set; }

    public virtual Guid? BindStaff { get; set; }

    public virtual DateTime? BindTime { get; set; }

    public virtual Guid? BindStore { get; set; }

    public virtual string OpenId { get; set; }

    public virtual string UnionId { get; set; }

    public virtual string MemberCardNo { get; set; }

    public virtual string Tel { get; set; }

    public virtual string Tex { get; set; }

    public virtual string Mobi { get; set; }

    public virtual string QQ { get; set; }

    public virtual string MSN { get; set; }

    public virtual string Province { get; set; }

    public virtual string City { get; set; }

    public virtual string PostalCode { get; set; }

    public virtual string Address { get; set; }

    public virtual string MaritalStatus { get; set; }

    public virtual string Education { get; set; }

    public virtual string IdCard { get; set; }

    public virtual string Industry { get; set; }

    public virtual string Occupation { get; set; }

    public virtual decimal AnnualIncome { get; set; }

    public virtual string Company { get; set; }

    public virtual string Position { get; set; }

    public virtual string Hobbies { get; set; }

    public virtual string AllowContact { get; set; }

    public virtual string AcceptedMessages { get; set; }

    public virtual string WebSiteType { get; set; }

    public virtual string SinaWeibo { get; set; }

    public virtual string TencentWeibo { get; set; }

    public virtual string SohuWeibo { get; set; }

    public virtual string Magazines { get; set; }

    public virtual string Individualization { get; set; }

    public virtual string Remark { get; set; }

    protected Member()
    {

    }

    public Member(Guid id, [NotNull] string name, [NotNull] string phoneNumber)
        : base(id)
    {
        SetName(name);
        SetPhoneNumber(phoneNumber);
    }

    protected internal virtual void SetName([NotNull] string name)
    {
        Name = Check.NotNullOrWhiteSpace(name, nameof(name), MemberConsts.MaxNameLength);
    }

    protected internal virtual void SetPhoneNumber([NotNull] string phoneNumber)
    {
        Name = Check.NotNullOrWhiteSpace(phoneNumber, nameof(phoneNumber), MemberConsts.MaxNameLength);
    }
}
